/*
 * @Descripttion: 应用程序请求中间件，在每次请求时触发。可在配置文件中设置是否启用
 * @version: 
 * @Author: turingchang
 * @Date: 2020-08-23 08:59:54
 * @LastEditors: turingchang
 * @LastEditTime: 2020-12-25 16:47:43
 */

const plugin = require('../../config/plugin');

module.exports = (options, app) => {
    return async function scheduleHandler(ctx, next) {   
        if(plugin.sequelize.enable === true){
            if (options.enable === true){
                await ctx.service.job.job.start();          
                await next(options);  
            }else{
                await next(options);
            }
        }else{
            await next(options);
        }
    };

};